package com.shoeshopping.dao.joseph;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.shoeshopping.entity.Goods;
import com.shoeshopping.utils.pc.HibernateUtils;

@Component("goodsDao")
public class GoodsDaoImpl implements GoodsDao {

	@Override
	public List getGoodsByType(String type) {
		List goodsList;
		String hql= "from Goods as g where g.type = :type";
		Session session = HibernateUtils.getSession();
		session.beginTransaction();
		Query query = session.createQuery(hql);
		query.setString("type", type);
		goodsList = query.list();
		session.getTransaction().commit();
		return goodsList;
	}
	
	@Override
	public List getAllGoods() {
		List goodsList;
		String hql= "from Goods";
		Session session = HibernateUtils.getSession();
		session.beginTransaction();
		Query query = session.createQuery(hql);
		goodsList = query.list();
		session.getTransaction().commit();
		return goodsList;
	}
	
	
	@Override
	public boolean updateGoods(Goods goods) {
		return false;
	}

	@Override
	public boolean deleteGoods(Goods goods) {
		return false;
	}

	@Override
	public boolean addGoods(Goods goods) {
		return false;
	}

}
